<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是根文件系统——Buildroot构建rootfs的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV05-04-根文件系统-02-Buildroot-03-Buildroot构建rootfs">
<meta property="og:url" content="https://sumumm.github.io/post/bdadd1c2.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是根文件系统——Buildroot构建rootfs的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127232816988.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20230805203210662.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127233925064.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20230805204036526.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241102201510703.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241102201541457.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241102203639580.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241102203727046.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20230805214354595-1732721156849-29.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127234632389.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127234813025.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127234934619.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20230805215536535.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127235140381.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127235403182.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127235808099.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241128000749251.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241128000855547.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241128001020376.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241128001339253.png">
<meta property="article:published_time" content="2024-11-29T02:27:27.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.046Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="LV05-系统镜像">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127232816988.png">


<link rel="canonical" href="https://sumumm.github.io/post/bdadd1c2.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":"","permalink":"https://sumumm.github.io/post/bdadd1c2.html","path":"post/bdadd1c2.html","title":"LV05-04-根文件系统-02-Buildroot-03-Buildroot构建rootfs"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV05-04-根文件系统-02-Buildroot-03-Buildroot构建rootfs | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-text">一、文件系统</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81buildroot%E6%9E%84%E5%BB%BA%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="nav-text">二、buildroot构建根文件系统</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81buildroot%E9%85%8D%E7%BD%AE"><span class="nav-text">三、buildroot配置</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E6%89%93%E5%BC%80%E9%85%8D%E7%BD%AE%E7%95%8C%E9%9D%A2"><span class="nav-text">1. 打开配置界面</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E9%85%8D%E7%BD%AEbuildboot"><span class="nav-text">2. 配置buildboot</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E9%85%8D%E7%BD%AE-Target-options"><span class="nav-text">2.1 配置 Target options  </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E9%85%8D%E7%BD%AE-Toolchain"><span class="nav-text">2.2 配置 Toolchain  </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-%E9%85%8D%E7%BD%AE-System-configuration"><span class="nav-text">2.3 配置 System configuration</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-4-%E9%85%8D%E7%BD%AE-Filesystem-images"><span class="nav-text">2.4 配置 Filesystem images  </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-5-%E7%A6%81%E6%AD%A2%E7%BC%96%E8%AF%91-Linux-%E5%86%85%E6%A0%B8%E5%92%8C-uboot"><span class="nav-text">2.5 禁止编译 Linux 内核和 uboot  </span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-6-%E9%85%8D%E7%BD%AE-Target-packages"><span class="nav-text">2.6 配置 Target packages  </span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E7%BC%96%E8%AF%91-buildroot"><span class="nav-text">3. 编译 buildroot</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E4%B8%8B%E8%BD%BD%E5%87%BA%E9%94%99%E6%80%8E%E4%B9%88%E5%8A%9E%EF%BC%9F"><span class="nav-text">3.1 下载出错怎么办？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-kernel-headers%E6%8A%A5%E9%94%99"><span class="nav-text">3.2 kernel headers报错</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-3-%E6%96%B0%E7%89%88%E6%9C%AC%E7%9A%84%E4%B8%80%E4%B8%AA%E9%97%AE%E9%A2%98"><span class="nav-text">3.3 新版本的一个问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-4-%E7%BC%96%E8%AF%91%E6%88%90%E5%8A%9F"><span class="nav-text">3.4 编译成功</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-4-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E6%B5%8B%E8%AF%95"><span class="nav-text">3.4 根文件系统测试</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81buildroot%E4%B8%8B%E7%9A%84busybox"><span class="nav-text">四、buildroot下的busybox</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-busybox-%E9%85%8D%E7%BD%AE"><span class="nav-text">1. busybox 配置  </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E4%B8%AD%E6%96%87%E6%94%AF%E6%8C%81"><span class="nav-text">2. 中文支持</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E7%BC%96%E8%AF%91busybox"><span class="nav-text">3. 编译busybox</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%94%E3%80%81%E7%BB%88%E7%AB%AF%E9%85%8D%E7%BD%AE"><span class="nav-text">五、终端配置</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%BB%88%E7%AB%AF%E6%8F%90%E7%A4%BA%E7%AC%A6"><span class="nav-text">1. 终端提示符</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E7%BB%88%E7%AB%AF%E5%AE%BD%E5%BA%A6"><span class="nav-text">2. 终端宽度</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/bdadd1c2.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV05-04-根文件系统-02-Buildroot-03-Buildroot构建rootfs | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV05-04-根文件系统-02-Buildroot-03-Buildroot构建rootfs
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2024-11-29 10:27:27" itemprop="dateCreated datePublished" datetime="2024-11-29T10:27:27+08:00">2024-11-29</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/" itemprop="url" rel="index"><span itemprop="name">02IMX6ULL平台</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/" itemprop="url" rel="index"><span itemprop="name">LV05-系统镜像</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>7.2k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>26 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是根文件系统——Buildroot构建rootfs的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" rowspan="5">PC端开发环境</td>        <td align="center" width=150px>Windows</td>        <td align="left">Windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu20.04.2的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 17 Pro</td>        <td align="left">17.6.0 build-24238078</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>    </tr>    <tr>        <td align="center">Win32DiskImager</td>        <td align="left">Win32DiskImager v1.0</td>      </tr>    <tr>        <td align="center" rowspan="3">Linux开发板环境</td>        <td align="center">Linux开发板</td>        <td align="left">正点原子 i.MX6ULL Linux 阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，使用的uboot版本为U-Boot 2019.04</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.19.71(NXP官方提供)</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="5">官方网站</td>        <td align="left"><a href="https://www.arm.com/" target="_blank">https://www.arm.com/</a></td>        <td align="left">ARM官方网站，在这里我们可以找到Cotex-Mx以及ARMVx的一些文档</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/" target="_blank">https://www.nxp.com.cn/ </a></td>        <td align="left">NXP官方网站</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxpic.org.cn/" target="_blank">https://www.nxpic.org.cn/</a></td><td align="left">NXP 官方社区</td>    </tr>    <tr>        <td align="left"><a href="https://u-boot.readthedocs.io/en/latest/" target="_blank">https://u-boot.readthedocs.io/en/latest/</a></td><td align="left">u-boot官网</td>    </tr>    <tr>        <td align="left"><a href="https://www.kernel.org/" target="_blank">https://www.kernel.org/</a></td><td align="left">linux内核官网</td>    </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="3">NXP</td>        <td align="left"><a href="https://github.com/nxp-imx" target="_blank">https://github.com/nxp-imx</a></td>        <td align="left">NXP imx开发资源GitHub组织，里边会有u-boot和linux内核的仓库</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/linux-imx/releases/tag/v4.19.71" target="_blank">nxp-imx/linux-imx/releases/tag/v4.19.71</a></td>        <td align="left">NXP linux内核仓库tags中的v4.19.71</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/uboot-imx/releases/tag/rel_imx_4.19.35_1.1.0" target="_blank">nxp-imx/uboot-imx/releases/tag/rel_imx_4.19.35_1.1.0</a></td>        <td align="left">NXP u-boot仓库tags中的rel_imx_4.19.35_1.1.0</td>    </tr>    <tr>        <td align="center" rowspan="2">I.MX6ULL</td>        <td align="left"><a href="https://www.nxp.com.cn/docs/en/data-sheet/IMX6ULLIEC.pdf" target="_blank">i.MX 6ULL Applications Processors for Industrial Products</a></td>        <td align="left">I.MX6ULL 芯片手册（datasheet，可以在线查看）</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/webapp/Download?colCode=IMX6ULLRM&lang_cd=zh" target="_blank">i.MX 6ULL Applications ProcessorReference Manual</a></td>        <td align="left">I.MX6ULL 参考手册（下载后才能查看，需要登录NXP官网）</td>    </tr>    <tr>        <td align="center" rowspan="2">Source Code</td>        <td align="left"><a href="https://elixir.bootlin.com/linux/latest/source" target="_blank">https://elixir.bootlin.com/linux/latest/source</a></td>        <td align="left">linux kernel源码</td>    </tr>    <tr>        <td align="left"><a href="https://elixir.bootlin.com/u-boot/latest/source" target="_blank">https://elixir.bootlin.com/u-boot/latest/source</a></td>        <td align="left">uboot源码</td>    </tr></table>
              </div>
            </details>

<h1 id="一、文件系统"><a href="#一、文件系统" class="headerlink" title="一、文件系统"></a><font size=3>一、文件系统</font></h1><p>我们回顾一下文件系统的概念：</p>
<p>我们先来看一下Linux是如何存储数据的。一般情况下，字符设备以串行方式存储和获取数据，串口是最典型的字符设备；而块设备会一次存取或者获取大小相同的一块区域内的数据。例如，一个硬 盘控制器可以向物理存储介质上指定可寻址地址，一次传送或接收512字节的数据，文件系统正是建立在块设备之上的。</p>
<p>文件系统是存在于一个物理设备的逻辑分区之上的。分区就是对一个物理介质（磁盘、闪存）的逻辑划分，该物理介质上的数据在给定分区类型上按照特定的规则进行组织，物理设备可以只有一个独立分区包含所有可用空间，也可以被划分为多个分区以满足特定需要，就好比我们电脑的磁盘，划分为多个分区以用于不同的需求。</p>
<p>简单了解了文件系统的概念，那么接下来我们就动手制作一个文件系统。</p>
<h1 id="二、buildroot构建根文件系统"><a href="#二、buildroot构建根文件系统" class="headerlink" title="二、buildroot构建根文件系统"></a><font size=3>二、buildroot构建根文件系统</font></h1><p>文件系统通常要包含很多第三方软件，比如busybox，tslib，qt，vim，交叉编译工具等，为了避免繁杂的移植工作，buildroot应运而生。用户可以直接通过make menuconfig配置自己需要的功能，把不需要的功能去掉，再执行make指令编译，buildroot就会自动从指定的服务器上下载源码包，自动编译，自动搭建成我们所需要的嵌入式根文件系统。</p>
<p>buildroot的文件系统（rootfs）构建流程有一个框架，有些部分是buildroot本身就集成的，但还是有些细节需要自己来实现，我们需要按照格式写脚本，提供必要的构建细节，并且配置整个系统，总之，rootfs是Buildroot中最为复杂的部分。</p>
<p>一般来说，buildroot构建文件系统的运作过程如下：</p>
<p>（1）buildroot将system&#x2F;skeleton&#x2F;目录下的内容拷贝到output&#x2F;target目录下下作为rootfs的模板。</p>
<p>（2）将output&#x2F;staging&#x2F;目录下的工具链中动态库拷贝到output&#x2F;target&#x2F;对应的目录下。</p>
<p>（3）分别编译每一个应用的package，并将生成的动态库和bin文件install到output&#x2F;target&#x2F;对应的目录下。</p>
<p>（4）将package&#x2F;initscripts&#x2F;目录下的系统启动脚本install到output&#x2F;target&#x2F;对应的目录下。</p>
<p>（5）构建fakeroot环境，在fakeroot环境下修改output&#x2F;target&#x2F;中对应的目录文件权限，制作dev节点，并根据用户的配置制作出rootfs 镜像。</p>
<p>fakeroot是一个主机上使用的软件包，它会被buildroot下载编译，用于为构建rootfs提供一个虚拟的root权限环境，只有在root权限下，才能把output&#x2F;target&#x2F;中的目录和文件变成root用户，并创建dev节点。有了fakeroot环境，系统构建者无需获取主机的root权限， 也能在fakeroot下把文件改为root用户，并制作root方式。</p>
<h1 id="三、buildroot配置"><a href="#三、buildroot配置" class="headerlink" title="三、buildroot配置"></a><font size=3>三、buildroot配置</font></h1><h2 id="1-打开配置界面"><a href="#1-打开配置界面" class="headerlink" title="1. 打开配置界面"></a><font size=3>1. 打开配置界面</font></h2><p>buildroot 和 uboot、 Linux kernel 一样也支持图形化配置，输入如下命令即可打开图形化配置界：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig</span><br><span class="line">make menuconfig # 好像也可以这样用，因为这里只是配置，后边编译的话会自动使用交叉编译工具链</span><br></pre></td></tr></table></figure>

<p>然后就会打开图形配置界面，如下所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127232816988.png" alt="image-20241127232816988" />

<h2 id="2-配置buildboot"><a href="#2-配置buildboot" class="headerlink" title="2. 配置buildboot"></a><font size=3>2. 配置buildboot</font></h2><h3 id="2-1-配置-Target-options"><a href="#2-1-配置-Target-options" class="headerlink" title="2.1 配置 Target options  "></a><font size=3>2.1 配置 Target options  </font></h3><p>首先配置 Target options 选项，需要配置的项目和其对应的内容如下(“&#x3D;”号后面是配置项要选择的内容 )：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">Target options</span><br><span class="line">    -&gt; Target Architecture = ARM (little endian)</span><br><span class="line">    -&gt; Target Architecture Variant = cortex-A7</span><br><span class="line">    -&gt; Target ABI = EABIhf</span><br><span class="line">    -&gt; Floating point strategy = NEON/VFPv4</span><br><span class="line">    -&gt; ARM instruction set = ARM</span><br><span class="line">    -&gt; Target Binary Format = ELF</span><br></pre></td></tr></table></figure>

<p>如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"> /home/sumu/7Linux/buildroot-2023.05.1/.config - Buildroot 2023.05.1 Configurati</span><br><span class="line">o→ Target options ─────────────────────────────────────────────────────────────</span><br><span class="line">  ┌──────────────────────────── Target options ─────────────────────────────┐</span><br><span class="line">  │  Arrow keys navigate the menu.  &lt;Enter&gt; selects submenus ---&gt; (or empty │  </span><br><span class="line">  │  submenus ----).  Highlighted letters are hotkeys.  Pressing &lt;Y&gt;        │  </span><br><span class="line">  │  selects a feature, while &lt;N&gt; excludes a feature.  Press &lt;Esc&gt;&lt;Esc&gt; to  │  </span><br><span class="line">  │  exit, &lt;?&gt; for Help, &lt;/&gt; for Search.  Legend: [*] feature is selected   │  </span><br><span class="line">  │ ┌─────────────────────────────────────────────────────────────────────┐ │  </span><br><span class="line">  │ │        Target Architecture (ARM (little endian))  ---&gt;              │ │  </span><br><span class="line">  │ │        Target Architecture Variant (cortex-A7)  ---&gt;                │ │  </span><br><span class="line">  │ │        Target ABI (EABIhf)  ---&gt;                                    │ │  </span><br><span class="line">  │ │        Floating point strategy (NEON/VFPv4)  ---&gt;                   │ │  </span><br><span class="line">  │ │        ARM instruction set (ARM)  ---&gt;                              │ │  </span><br><span class="line">  │ │        Target Binary Format (ELF)  ---&gt;                             │ │  </span><br><span class="line">  │ └─────────────────────────────────────────────────────────────────────┘ │  </span><br><span class="line">  ├─────────────────────────────────────────────────────────────────────────┤  </span><br><span class="line">  │        &lt;Select&gt;    &lt; Exit &gt;    &lt; Help &gt;    &lt; Save &gt;    &lt; Load &gt;         │  </span><br><span class="line">  └─────────────────────────────────────────────────────────────────────────┘  </span><br></pre></td></tr></table></figure>

<h3 id="2-2-配置-Toolchain"><a href="#2-2-配置-Toolchain" class="headerlink" title="2.2 配置 Toolchain  "></a><font size=3>2.2 配置 Toolchain  </font></h3><p>此配置项用于配置交叉编译工具链，也就是交叉编译器，这里设置为我们自己所使用的交叉编译器即可。 buildroot 其实是可以自动下载交叉编译器的，但是都是从国外服务器下载的，鉴于国内的网络环境，强烈建议设置成自己所使用的交叉编译器。需要配置的项目和其对应的内容如下：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">Toolchain</span><br><span class="line">    -&gt; Toolchain type = External toolchain</span><br><span class="line">    -&gt; Toolchain = Custom toolchain # 用户自己的交叉编译器</span><br><span class="line">    -&gt; Toolchain origin = Pre-installed toolchain # 预装的编译器</span><br><span class="line">    -&gt; Toolchain path =/home/hk/2software/gcc-linaro-4.9.4</span><br><span class="line">    -&gt; Toolchain prefix = $(ARCH)-linux-gnueabihf  # 前缀</span><br><span class="line">    -&gt; External toolchain gcc version = 4.9.x</span><br><span class="line">    -&gt; External toolchain kernel headers series = 4.1.x</span><br><span class="line">    -&gt; External toolchain C library = glibc/eglibc</span><br><span class="line">    -&gt; [*] Toolchain has SSP support? (NEW) # 选中</span><br><span class="line">    -&gt; [*] Toolchain has RPC support? (NEW) # 选中</span><br><span class="line">    -&gt; [*] Toolchain has C++ support?       # 选中</span><br><span class="line">    -&gt; [*] Enable      MMU support (NEW)    # 选中</span><br></pre></td></tr></table></figure>

<blockquote>
<p>Toolchain 下几个比较重要的选项需要说明一下，如下所示：</p>
<ul>
<li><p>Toolchain：设置为 Custom toolchain，表示使用用户自己的交叉编译器。</p>
</li>
<li><p>Toolchain origin：设置为 Pre-installed toolchain，表示使用预装的交叉编译器。</p>
</li>
<li><p>Toolchain path：设置自己安装的交叉编译器绝对路径！ buildroot 要用到。</p>
</li>
<li><p>Toolchain prefix：设置交叉编译器前缀，要根据自己实际所使用的交叉编译器来设置，比如我们使用的是 arm-linux-gnueabihf-gcc，因此前缀就是$(ARCH)-linux-gnueabihf，其中 ARCH我们前面已经设置为了 arm。</p>
</li>
</ul>
</blockquote>
<p>配置完后图形界面如下所示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"> /home/sumu/7Linux/buildroot-2023.05.1/.config - Buildroot 2023.05.1 Configurati</span><br><span class="line">o→ Toolchain ──────────────────────────────────────────────────────────────────</span><br><span class="line">  ┌─────────────────────────────── Toolchain ───────────────────────────────┐</span><br><span class="line">  │  Arrow keys navigate the menu.  &lt;Enter&gt; selects submenus ---&gt; (or empty │  </span><br><span class="line">  │  submenus ----).  Highlighted letters are hotkeys.  Pressing &lt;Y&gt;        │  </span><br><span class="line">  │  selects a feature, while &lt;N&gt; excludes a feature.  Press &lt;Esc&gt;&lt;Esc&gt; to  │  </span><br><span class="line">  │  exit, &lt;?&gt; for Help, &lt;/&gt; for Search.  Legend: [*] feature is selected   │  </span><br><span class="line">  │ ┌─────────────────────────────────────────────────────────────────────┐ │  </span><br><span class="line">  │ │        Toolchain type (External toolchain)  ---&gt;                    │ │  </span><br><span class="line">  │ │        *** Toolchain External Options ***                           │ │  </span><br><span class="line">  │ │        Toolchain (Custom toolchain)  ---&gt;                           │ │  </span><br><span class="line">  │ │        Toolchain origin (Pre-installed toolchain)  ---&gt;             │ │  </span><br><span class="line">  │ │    (/home/sumu/2software/gcc-arm-linux-gnueabihf-8.3.0) Toolchain pa│ │  </span><br><span class="line">  │ │    ($(ARCH)-linux-gnueabihf) Toolchain prefix                       │ │  </span><br><span class="line">  │ │        External toolchain gcc version (8.x)  ---&gt;                   │ │  </span><br><span class="line">  │ │        External toolchain kernel headers series (4.19.x)  ---&gt;      │ │  </span><br><span class="line">  │ │        External toolchain C library (glibc)  ---&gt;                   │ │  </span><br><span class="line">  │ │    [*] Toolchain has SSP support?                                   │ │  </span><br><span class="line">  │ │    [*]   Toolchain has SSP strong support?                          │ │  </span><br><span class="line">  │ │    [*] Toolchain has RPC support?                                   │ │  </span><br><span class="line">  │ │    [*] Toolchain has C++ support?                                   │ │  </span><br><span class="line">  │ │    [ ] Toolchain has D support?                                     │ │  </span><br><span class="line">  │ │    [ ] Toolchain has Fortran support?                               │ │  </span><br><span class="line">  │ │    [ ] Toolchain has OpenMP support?                                │ │   </span><br><span class="line">  │ │    [ ] Copy gdb server to the Target                                │ │  </span><br><span class="line">  │ │        *** Host GDB Options ***                                     │ │  </span><br><span class="line">  │ │    [ ] Build cross gdb for the host                                 │ │  </span><br><span class="line">  │ │        *** Toolchain Generic Options ***                            │ │  </span><br><span class="line">  │ │    [ ] Copy gconv libraries                                         │ │  </span><br><span class="line">  │ │    ()  Extra toolchain libraries to be copied to target             │ │  </span><br><span class="line">  │ │    ()  Target Optimizations                                         │ │  </span><br><span class="line">  │ │    ()  Target linker options                                        │ │  </span><br><span class="line">  │ └─────────────────────────────────────────────────────────────────────┘ │  </span><br><span class="line">  ├─────────────────────────────────────────────────────────────────────────┤  </span><br><span class="line">  │        &lt;Select&gt;    &lt; Exit &gt;    &lt; Help &gt;    &lt; Save &gt;    &lt; Load &gt;         │  </span><br><span class="line">  └─────────────────────────────────────────────────────────────────────────┘  </span><br></pre></td></tr></table></figure>

<p>需要注意一下我后来升级了交叉编译工具链版本和内核版本，这里界面菜单中的东西就跟着改了一下。</p>
<h3 id="2-3-配置-System-configuration"><a href="#2-3-配置-System-configuration" class="headerlink" title="2.3 配置 System configuration"></a><font size=3>2.3 配置 System configuration</font></h3><p>此选项用于设置一些系统配置，比如开发板名字、欢迎语、用户名、密码等。需要配置的项目和其对应的内容如下：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">System configuration</span><br><span class="line">    -&gt; System hostname = alpha_imx6ull # 平台名字，自行设置</span><br><span class="line">    -&gt; System banner = Welcome to alpha i.mx6ull # 欢迎语</span><br><span class="line">    -&gt; Init system = BusyBox                     # 使用 busybox</span><br><span class="line">    -&gt; /dev management = Dynamic using devtmpfs + mdev # 使用 mdev</span><br><span class="line">    -&gt; [*] Enable root login with password (NEW)       # 使能登录密码</span><br><span class="line">    -&gt; Root password = 123456                          # 登录密码为 123456</span><br></pre></td></tr></table></figure>

<p>在 System configuration 选项中可以配置平台名字，登录密码等信息。如下所示：</p>
  <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"> /home/sumu/7Linux/buildroot-2023.05.1/.config - Buildroot 2023.05.1 Configurati</span><br><span class="line">o→ System configuration ───────────────────────────────────────────────────────</span><br><span class="line">  ┌───────────────────────── System configuration ──────────────────────────┐</span><br><span class="line">  │  Arrow keys navigate the menu.  &lt;Enter&gt; selects submenus ---&gt; (or empty │  </span><br><span class="line">  │  submenus ----).  Highlighted letters are hotkeys.  Pressing &lt;Y&gt;        │  </span><br><span class="line">  │  selects a feature, while &lt;N&gt; excludes a feature.  Press &lt;Esc&gt;&lt;Esc&gt; to  │  </span><br><span class="line">  │  exit, &lt;?&gt; for Help, &lt;/&gt; for Search.  Legend: [*] feature is selected   │  </span><br><span class="line">  │ ┌─────────────────────────────────────────────────────────────────────┐ │  </span><br><span class="line">  │ │        Root FS skeleton (default target skeleton)  ---&gt;             │ │  </span><br><span class="line">  │ │    (alpha-imx6ull) System hostname                                  │ │  </span><br><span class="line">  │ │    (Welcome to Alpha IMX6ULL) System banner                         │ │  </span><br><span class="line">  │ │        Passwords encoding (sha-256)  ---&gt;                           │ │  </span><br><span class="line">  │ │        Init system (BusyBox)  ---&gt;                                  │ │  </span><br><span class="line">  │ │        /dev management (Dynamic using devtmpfs + mdev)  ---&gt;        │ │  </span><br><span class="line">  │ │    (system/device_table.txt) Path to the permission tables          │ │  </span><br><span class="line">  │ │    [ ] support extended attributes in device tables                 │ │  </span><br><span class="line">  │ │    [ ] Use symlinks to /usr for /bin, /sbin and /lib                │ │  </span><br><span class="line">  │ │    [*] Enable root login with password                              │ │  </span><br><span class="line">  │ │    ()    Root password                                              │ │  </span><br><span class="line">  │ │        /bin/sh (busybox&#x27; default shell)  ---&gt;                       │ │  </span><br><span class="line">  │ │    [*] Run a getty (login prompt) after boot  ---&gt;                  │ │  </span><br><span class="line">  │ │    [*] remount root filesystem read-write during boot               │ │  </span><br><span class="line">  │ │    ()  Network interface to configure through DHCP                  │ │  </span><br><span class="line">  │ │    (/bin:/sbin:/usr/bin:/usr/sbin) Set the system&#x27;s default PATH    │ │  </span><br><span class="line">  │ │    [*] Purge unwanted locales                                       │ │  </span><br><span class="line">  │ │    (C en_US) Locales to keep                                        │ │  </span><br><span class="line">  │ │    ()  Generate locale data                                         │ │  </span><br><span class="line">  │ │    [ ] Enable Native Language Support (NLS)                         │ │  </span><br><span class="line">  │ │    [ ] Install timezone info                                        │ │  </span><br><span class="line">  │ │    ()  Path to the users tables                                     │ │  </span><br><span class="line">  │ │    ()  Root filesystem overlay directories                          │ │  </span><br><span class="line">  │ │    ()  Custom scripts to run before commencing the build            │ │  </span><br><span class="line">  │ │    ()  Custom scripts to run before creating filesystem images      │ │  </span><br><span class="line">  │ │    ()  Custom scripts to run inside the fakeroot environment        │ │  </span><br><span class="line">  │ │    ()  Custom scripts to run after creating filesystem images       │ │  </span><br><span class="line">  │ └─────────────────────────────────────────────────────────────────────┘ │  </span><br><span class="line">  ├─────────────────────────────────────────────────────────────────────────┤  </span><br><span class="line">  │        &lt;Select&gt;    &lt; Exit &gt;    &lt; Help &gt;    &lt; Save &gt;    &lt; Load &gt;         │  </span><br><span class="line">  └─────────────────────────────────────────────────────────────────────────┘  </span><br></pre></td></tr></table></figure>

<h3 id="2-4-配置-Filesystem-images"><a href="#2-4-配置-Filesystem-images" class="headerlink" title="2.4 配置 Filesystem images  "></a><font size=3>2.4 配置 Filesystem images  </font></h3><p>此选项配置我们最终制作的根文件系统为什么格式的，配置如下：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">-&gt; </span><span class="language-bash">Filesystem images</span></span><br><span class="line">    -&gt; [*] ext2/3/4 root filesystem # 如果是 EMMC 或 SD 卡的话就用 ext3/ext4</span><br><span class="line">    -&gt; ext2/3/4 variant = ext4      # 选择 ext4 格式</span><br><span class="line">    -&gt; [*] ubi image containing an ubifs root filesystem # 如果使用 NAND 的话就用 ubifs</span><br></pre></td></tr></table></figure>

<p>对于 I.MX6U 来说此选项不用配置，因为我们是通过 Mfgtool 工具将根文件系统烧写到开发板上的 EMMC&#x2F;SD 卡中，烧写的时候需要自己对根文件系统进行打包。  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line"> /home/sumu/7Linux/buildroot-2023.05.1/.config - Buildroot 2023.05.1 Configurati</span><br><span class="line">o→ Filesystem images ──────────────────────────────────────────────────────────</span><br><span class="line">  ┌─────────────────────────── Filesystem images ───────────────────────────┐</span><br><span class="line">  │  Arrow keys navigate the menu.  &lt;Enter&gt; selects submenus ---&gt; (or empty │  </span><br><span class="line">  │  submenus ----).  Highlighted letters are hotkeys.  Pressing &lt;Y&gt;        │  </span><br><span class="line">  │  selects a feature, while &lt;N&gt; excludes a feature.  Press &lt;Esc&gt;&lt;Esc&gt; to  │  </span><br><span class="line">  │  exit, &lt;?&gt; for Help, &lt;/&gt; for Search.  Legend: [*] feature is selected   │  </span><br><span class="line">  │ ┌─────────────────────────────────────────────────────────────────────┐ │  </span><br><span class="line">  │ │    [ ] axfs root filesystem                                         │ │  </span><br><span class="line">  │ │    [ ] btrfs root filesystem                                        │ │  </span><br><span class="line">  │ │    [ ] cloop root filesystem for the target device                  │ │  </span><br><span class="line">  │ │    [ ] cpio the root filesystem (for use as an initial RAM filesyste│ │  </span><br><span class="line">  │ │    [ ] cramfs root filesystem                                       │ │  </span><br><span class="line">  │ │    [ ] erofs root filesystem                                        │ │  </span><br><span class="line">  │ │    [*] ext2/3/4 root filesystem                                     │ │  </span><br><span class="line">  │ │          ext2/3/4 variant (ext4)  ---&gt;                              │ │  </span><br><span class="line">  │ │    (rootfs) filesystem label                                        │ │  </span><br><span class="line">  │ │    (60M) exact size                                                 │ │  </span><br><span class="line">  │ │    (0)   exact number of inodes (leave at 0 for auto calculation)   │ │  </span><br><span class="line">  │ │    (256) inode size                                                 │ │  </span><br><span class="line">  │ │    (5)   reserved blocks percentage                                 │ │  </span><br><span class="line">  │ │    (-O ^64bit) additional mke2fs options                            │ │  </span><br><span class="line">  │ │          Compression method (no compression)  ---&gt;                  │ │  </span><br><span class="line">  │ │    [ ] f2fs root filesystem                                         │ │  </span><br><span class="line">  │ │        *** initramfs needs a Linux kernel to be built ***           │ │  </span><br><span class="line">  │ │    [ ] jffs2 root filesystem                                        │ │  </span><br><span class="line">  │ │    [ ] oci image                                                    │ │  </span><br><span class="line">  │ │    [ ] romfs root filesystem                                        │ │  </span><br><span class="line">  │ │    [ ] squashfs root filesystem                                     │ │  </span><br><span class="line">  │ │    [*] tar the root filesystem                                      │ │  </span><br><span class="line">  │ │          Compression method (no compression)  ---&gt;                  │ │  </span><br><span class="line">  │ │    ()    other random options to pass to tar                        │ │  </span><br><span class="line">  │ │    [*] ubi image containing an ubifs root filesystem                │ │  </span><br><span class="line">  │ │    (0x20000) physical eraseblock size                               │ │  </span><br><span class="line">  │ │    (512) sub-page size                                              │ │  </span><br><span class="line">  │ │    [ ]   Use custom config file                                     │ │  </span><br><span class="line">  │ │    ()    Additional ubinize options                                 │ │  </span><br><span class="line">  │ │    -*- ubifs root filesystem                                        │ │  </span><br><span class="line">  │ │    (0x1f800) logical eraseblock size                                │ │  </span><br><span class="line">  │ │    (0x800) minimum I/O unit size                                    │ │  </span><br><span class="line">  │ │    (2048) maximum logical eraseblock count                          │ │  </span><br><span class="line">  │ │          ubifs runtime compression (lzo)  ---&gt;                      │ │  </span><br><span class="line">  │ │          Compression method (no compression)  ---&gt;                  │ │  </span><br><span class="line">  │ │    ()    Additional mkfs.ubifs options                              │ │  </span><br><span class="line">  │ │    [ ] yaffs2 root filesystem                                       │ │  </span><br><span class="line">  │ └─────────────────────────────────────────────────────────────────────┘ │  </span><br><span class="line">  ├─────────────────────────────────────────────────────────────────────────┤  </span><br><span class="line">  │        &lt;Select&gt;    &lt; Exit &gt;    &lt; Help &gt;    &lt; Save &gt;    &lt; Load &gt;         │  </span><br><span class="line">  └─────────────────────────────────────────────────────────────────────────┘  </span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="2-5-禁止编译-Linux-内核和-uboot"><a href="#2-5-禁止编译-Linux-内核和-uboot" class="headerlink" title="2.5 禁止编译 Linux 内核和 uboot  "></a><font size=3>2.5 禁止编译 Linux 内核和 uboot  </font></h3><p>buildroot 不仅仅能构建根文件系统，也可以编译 linux 内核和 uboot。当配置 buildroot，使能 linux 内核和 uboot 以后 buildroot 就会自动下载最新的 linux 内核和 uboot 源码并编译。但是我们一般都不会使用 buildroot 下载的 linux 内核和 uboot，因为 buildroot 下载的 linux 和 uboot官方源码，里面会缺少很多驱动文件，而且最新的 linux 内核和 uboot 会对编译器版本号有要求，可能导致编译失败。因此我们需要配置 buildroot，关闭 linux 内核和 uboot 的编译，只使用buildroot 来构建根文件系统， 首先是禁止 Linux 内核的编译， 配置如下：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">-&gt; </span><span class="language-bash">Kernel</span></span><br><span class="line"><span class="meta prompt_">	-&gt; </span><span class="language-bash">[ ] Linux Kernel <span class="comment"># 不要选择编译 Linux Kernel 选项！</span></span></span><br><span class="line"><span class="meta prompt_">-&gt; </span><span class="language-bash">Bootloaders</span></span><br><span class="line"><span class="meta prompt_">	-&gt; </span><span class="language-bash">[ ] U-Boot       <span class="comment"># 不要选择编译 U-Boot 选项！</span></span></span><br></pre></td></tr></table></figure>

<ul>
<li>Kernel</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"> /home/sumu/7Linux/buildroot-2023.05.1/.config - Buildroot 2023.05.1 Configurati</span><br><span class="line">o→ Kernel ─────────────────────────────────────────────────────────────────────</span><br><span class="line">  ┌──────────────────────────────── Kernel ─────────────────────────────────┐</span><br><span class="line">  │  Arrow keys navigate the menu.  &lt;Enter&gt; selects submenus ---&gt; (or empty │  </span><br><span class="line">  │  submenus ----).  Highlighted letters are hotkeys.  Pressing &lt;Y&gt;        │  </span><br><span class="line">  │  selects a feature, while &lt;N&gt; excludes a feature.  Press &lt;Esc&gt;&lt;Esc&gt; to  │  </span><br><span class="line">  │  exit, &lt;?&gt; for Help, &lt;/&gt; for Search.  Legend: [*] feature is selected   │  </span><br><span class="line">  │ ┌─────────────────────────────────────────────────────────────────────┐ │  </span><br><span class="line">  │ │    [ ] Linux Kernel                                                 │ │  </span><br><span class="line">  │ │                                                                     │ │  </span><br><span class="line">  │ └─────────────────────────────────────────────────────────────────────┘ │  </span><br><span class="line">  ├─────────────────────────────────────────────────────────────────────────┤  </span><br><span class="line">  │        &lt;Select&gt;    &lt; Exit &gt;    &lt; Help &gt;    &lt; Save &gt;    &lt; Load &gt;         │  </span><br><span class="line">  └─────────────────────────────────────────────────────────────────────────┘  </span><br><span class="line">    </span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ul>
<li>Bootloaders</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"> /home/sumu/7Linux/buildroot-2023.05.1/.config - Buildroot 2023.05.1 Configurati</span><br><span class="line">o→ Bootloaders ────────────────────────────────────────────────────────────────</span><br><span class="line">  ┌────────────────────────────── Bootloaders ──────────────────────────────┐</span><br><span class="line">  │  Arrow keys navigate the menu.  &lt;Enter&gt; selects submenus ---&gt; (or empty │  </span><br><span class="line">  │  submenus ----).  Highlighted letters are hotkeys.  Pressing &lt;Y&gt;        │  </span><br><span class="line">  │  selects a feature, while &lt;N&gt; excludes a feature.  Press &lt;Esc&gt;&lt;Esc&gt; to  │  </span><br><span class="line">  │  exit, &lt;?&gt; for Help, &lt;/&gt; for Search.  Legend: [*] feature is selected   │  </span><br><span class="line">  │ ┌─────────────────────────────────────────────────────────────────────┐ │  </span><br><span class="line">  │ │    [ ] afboot-stm32                                                 │ │  </span><br><span class="line">  │ │    [ ] AT91 Bootstrap 3+                                            │ │  </span><br><span class="line">  │ │    [ ] ARM Trusted Firmware (ATF)                                   │ │  </span><br><span class="line">  │ │    [ ] Barebox                                                      │ │  </span><br><span class="line">  │ │    [ ] grub2                                                        │ │  </span><br><span class="line">  │ │    [ ] optee_os                                                     │ │  </span><br><span class="line">  │ │    [ ] s500-bootloader                                              │ │  </span><br><span class="line">  │ │    [ ] shim                                                         │ │  </span><br><span class="line">  │ │    [ ] U-Boot                                                       │ │  </span><br><span class="line">  │ │                                                                     │ │  </span><br><span class="line">  │ └─────────────────────────────────────────────────────────────────────┘ │  </span><br><span class="line">  ├─────────────────────────────────────────────────────────────────────────┤  </span><br><span class="line">  │        &lt;Select&gt;    &lt; Exit &gt;    &lt; Help &gt;    &lt; Save &gt;    &lt; Load &gt;         │  </span><br><span class="line">  └─────────────────────────────────────────────────────────────────────────┘  </span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="2-6-配置-Target-packages"><a href="#2-6-配置-Target-packages" class="headerlink" title="2.6 配置 Target packages  "></a><font size=3>2.6 配置 Target packages  </font></h3><p>此选项用于配置要选择的第三方库或软件、比如 alsa-utils、 ffmpeg、 iperf 等工具，但是现在我们先不选择第三方库，防止编译不下去！先编译一下最基本的根文件系统，如果没有问题的话再重新配置选择第三方库和软件。一次性配置太多的花，编译出问题的时候都不知道怎么找问题。  </p>
<h2 id="3-编译-buildroot"><a href="#3-编译-buildroot" class="headerlink" title="3. 编译 buildroot"></a><font size=3>3. 编译 buildroot</font></h2><p>配置完成以后就可以编译 buildroot 了，编译完成以后 buildroot 就会生成编译出来的根文件系统压缩包，我们可以直接使用。输入如下命令开始编译：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo make # 注意，一定要加 sudo，而且不能通过-jx 来指定多核编译！！！</span><br></pre></td></tr></table></figure>

<p>buildroot 编译的时候会先从网上下载所需的软件源码，有些软件源码可能下载不下来，这个时候就需要我们自行处理，这个后边再说。<br>buildroot 编译过程会很耗时，可能需要几个小时，这个时候耐心等待！buildroot 因为要从网上下载源码，因此可能存在有些源码无法下载或下载很慢的情况。</p>
<h3 id="3-1-下载出错怎么办？"><a href="#3-1-下载出错怎么办？" class="headerlink" title="3.1 下载出错怎么办？"></a><font size=3>3.1 下载出错怎么办？</font></h3><p>如下所示：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20230805203210662.png" alt="image-20230805203210662" style="zoom: 50%;" />

<p>比如说这个，就会下载失败，出现下载失败或者下载很慢怎么办？我们可以根据下载链接，自己科学上网一下，下载好放到buildroot源码目录的dl目录下，dl 文件夹专用用于存放下载下来的源码。  就比如上边的这个，我们可以点击这个链接：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">http://sources.buildroot.net/e2fsprogs/e2fsprogs-1.46.5.tar.xz</span><br></pre></td></tr></table></figure>

<p>直接下载好压缩包，将它放到dl目录下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127233925064.png" alt="image-20241127233925064" />

<p>然后我们再重新执行make命令就可以了。</p>
<h3 id="3-2-kernel-headers报错"><a href="#3-2-kernel-headers报错" class="headerlink" title="3.2 kernel headers报错"></a><font size=3>3.2 kernel headers报错</font></h3><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20230805204036526.png" alt="image-20230805204036526" style="zoom:50%;" />

<p>我的解决办法就是修改配置：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Toolchain</span><br><span class="line">    -&gt; External toolchain kernel headers series = 4.0.x</span><br></pre></td></tr></table></figure>

<p>修改这里的External toolchain kernel headers series版本，改成了4.0.x。</p>
<h3 id="3-3-新版本的一个问题"><a href="#3-3-新版本的一个问题" class="headerlink" title="3.3 新版本的一个问题"></a><font size=3>3.3 新版本的一个问题</font></h3><p>之前下载了一个2024.8-rc3的版本，执行make命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo make</span><br></pre></td></tr></table></figure>

<p>需要加sudo，否则报错：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241102201510703.png" alt="image-20241102201510703" />

<p>然后还会有这样一个报错：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241102201541457.png" alt="image-20241102201541457" />

<p>说是要这样解决：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">echo &quot;export set FORCE_UNSAFE_CONFIGURE=1&quot;  &gt;&gt; /etc/profile</span><br><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure>

<p>但是还是有问题，没解决掉，后来换回这个版本了：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://buildroot.org/downloads/buildroot-2023.05.1.tar.gz</span><br></pre></td></tr></table></figure>

<h3 id="3-4-编译成功"><a href="#3-4-编译成功" class="headerlink" title="3.4 编译成功"></a><font size=3>3.4 编译成功</font></h3><p>不出意外的话应该是可以编译成功的，没有什么特别的提示信息，只要不报错即可。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241102203639580.png" alt="image-20241102203639580" />

<h3 id="3-4-根文件系统测试"><a href="#3-4-根文件系统测试" class="headerlink" title="3.4 根文件系统测试"></a><font size=3>3.4 根文件系统测试</font></h3><p>编译结束后，会在buildroot源码目录的output目录中生成根文件系统：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241102203727046.png" alt="image-20241102203727046" />

<p>可以看出，编译出来了多种格式的 rootfs，比如 ext2、 ext4、 ubi 等。其中rootfs.tar 就是打包好的根文件系统，我们就使用 rootfs.tar 进行测试。在 nfs 目录下新建一个名为 buildrootfs 的文件夹  ，然后将rootfs.tar 拷贝到 buildrootfs 目录下并解压，命令如下：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p ~/4nfs/buildroot</span><br><span class="line">cp ~/7Linux/buildroot-2023.05.1/output/images/rootfs.tar ~/4nfs/buildroot</span><br><span class="line">cd ~/4nfs/buildroot</span><br><span class="line">tar -xf rootfs.tar</span><br><span class="line">rm rootfs.tar</span><br></pre></td></tr></table></figure>

<p>然后修改uboot的bootargs参数：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">=&gt; setenv bootargs &#x27;console=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.10.101:/home/sumu/4nfs/buildroot,proto=tcp rw ip=192.168.10.102:192.168.10.101:192.168.10.1:255.255.255.0::eth0:off init=/linuxrc&#x27;</span><br><span class="line">=&gt; saveenv </span><br></pre></td></tr></table></figure>

<p>然后重启就可以啦，要是制作没问题的话，是可以挂载成功的。首先要进入到&#x2F;lib&#x2F;modules 目录，但是默认没有，因此需要我们自行创建此目录。 buildroot 构建的根文件系统启动以后会输出我们前面设置的欢迎语“Welcome to alphai.mx6ull”。然后需要输入用户名和密码，用户名是“root”，密码就是我们前面配置 buildroot 的时候设置的 “123456” 。输入用户名和密码以后就可以进入系统中：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20230805214354595-1732721156849-29.png" alt="image-20230805214354595"  />

<p>可以看出的 buildroot 构建的根文件系统运行基本没有问题，但是这个根文件系统是最简单的，我们并没有在 buildroot 里面配置任何第三方的库和软件，接下来我们就配置 buildroot，使能一些常见的第三方软件。  </p>
<h1 id="四、buildroot下的busybox"><a href="#四、buildroot下的busybox" class="headerlink" title="四、buildroot下的busybox"></a><font size=3>四、buildroot下的busybox</font></h1><h2 id="1-busybox-配置"><a href="#1-busybox-配置" class="headerlink" title="1. busybox 配置  "></a><font size=3>1. busybox 配置  </font></h2><p>buildroot 在构建根文件系统的时候也是要用到 busybox 的，既然用到了 busybox 那么就涉及到 busybox 的配置。 buildroot 会自动下载 busybox 压缩包， buildroot 下载的源码压缩包都存放在&#x2F;dl 目录下，在 dl 目录下就有一个叫做“busybox”的文件夹，此目录下保存着 busybox 压缩包  ：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127234632389.png" alt="image-20241127234632389" />

<p>可以看出， buildroot 下载的 busybox 版本为 1.36.1。要想编译 busybox，必须对图中的压缩包进行解压缩， buildroot 将所有解压缩后的软件保存在buildroot源码目录的 output&#x2F;build 中，我们可以在找到 output&#x2F;build&#x2F;busybox-1.36.1 这个文件夹，此文件夹就是解压后的 busybox 源码，文件内容如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127234813025.png" alt="image-20241127234813025" />

<p>如果想要修改 busybox 源码的话就直接在图中找到相应的文件，然后修改即可。我们现在是要配置 buildroot 下的 busybox，因此肯定要打开 busybox 的配置界面，在 buildroot下打开 busybox 的配置界面输入如下命令：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd ~/7Linux/buildroot-2023.05.1</span><br><span class="line">sudo make busybox-menuconfig</span><br></pre></td></tr></table></figure>

<p>然后就会打开busybox的配置界面:</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127234934619.png" alt="image-20241127234934619" />

<p>想要怎么配置直接参考前边的busybox构建根文件系统的笔记即可。</p>
<h2 id="2-中文支持"><a href="#2-中文支持" class="headerlink" title="2. 中文支持"></a><font size=3>2. 中文支持</font></h2><p>用buildroot编译出来的根文件系统也是不支持中文的，但是由于它其实使用的是busybox，所以我们可以直接根据前边的busybox构建根文件系统的笔记来修改busybox的源码，使其支持中文，这个可以看后面busybox相关的笔记。</p>
<h2 id="3-编译busybox"><a href="#3-编译busybox" class="headerlink" title="3. 编译busybox"></a><font size=3>3. 编译busybox</font></h2><p>配置好以后就可以重新编译 buildroot 下的 busybox，进入到 buildroot 源码目录下，输入如下命令查看当前 buildroot 所有配置了的目标软件包，也就是 packages：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo make show-targets</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20230805215536535.png" alt="image-20230805215536535" style="zoom:50%;" />

<p>图中列出了当前 buildroot 中所有使能了的 packages 包，其中就包括 busybox，如果我们想单独编译并安装 busybox 的话执行下面命令即可：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo make busybox</span><br></pre></td></tr></table></figure>

<p>上述命令就会重新编译 busybox。编译完成以后重新编译 buildroot，主要是对其进行打包，输入如下命令：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo make</span><br></pre></td></tr></table></figure>

<p>重新编译完成以后查看一下 output&#x2F;images 目录下 rootfs.tar 的创建时间是否为刚刚编译的，如果不是的话就删除掉 rootfs.tar，然后重新执行“sudo make”重新编译一下即可。最后我们使用新的 rootfs.tar 启动 Linux 系统。  </p>
<h1 id="五、终端配置"><a href="#五、终端配置" class="headerlink" title="五、终端配置"></a><font size=3>五、终端配置</font></h1><h2 id="1-终端提示符"><a href="#1-终端提示符" class="headerlink" title="1. 终端提示符"></a><font size=3>1. 终端提示符</font></h2><p>buildroot构建的根文件系统中的命令提示符前边也是不会显示当前路径的：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127235140381.png" alt="image-20241127235140381" />

<p>我们可以，修改一下PS1变量，我们打开buildroot构建出来的根文件系统的 etc&#x2F;profile文件，找到如下代码：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">if [ &quot;$PS1&quot; ]; then</span><br><span class="line">        if [ &quot;`id -u`&quot; -eq 0 ]; then</span><br><span class="line">                export PS1=&#x27;# &#x27;</span><br><span class="line">        else</span><br><span class="line">                export PS1=&#x27;$ &#x27;</span><br><span class="line">        fi</span><br><span class="line">fi</span><br></pre></td></tr></table></figure>

<p>我们把它修改成如下的样子：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">PS1=&#x27;[\u@\h]:\w$:&#x27;</span><br><span class="line">export PS1</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127235403182.png" alt="image-20241127235403182" />

<p>然后我们再重启开发板就会看到命令提示符前边有显示路径啦：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241127235808099.png" alt="image-20241127235808099" />

<p>这里有一个网站可以帮助我们生成PS1变量的代码：<a target="_blank" rel="noopener" href="https://ezprompt.net/">Easy Bash Prompt Generator</a>，例如这样：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241128000749251.png" alt="image-20241128000749251" />

<p>重新修改后就可以得到这样的一个终端啦：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241128000855547.png" alt="image-20241128000855547" />

<h2 id="2-终端宽度"><a href="#2-终端宽度" class="headerlink" title="2. 终端宽度"></a><font size=3>2. 终端宽度</font></h2><p>当我们输入过长的命令的时候会出现换行的情况：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241128001020376.png" alt="image-20241128001020376" />

<p>这是终端的默认长度有问题，可以参考《01嵌入式开发&#x2F;02IMX6ULL平台&#x2F;LV02-开发环境&#x2F;LV02-04-终端配置-01-默认终端长度问题.md》解决。我们打开开发板的&#x2F;etc&#x2F;init.d&#x2F;rcS文件，去掉这两行：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">shopt -s checkwinsize</span><br><span class="line">resize</span><br></pre></td></tr></table></figure>

<p>没有的话就不管了。然后打开环境变量文件&#x2F;etc&#x2F;profile，添加如下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">shopt -s checkwinsize</span><br><span class="line">resize</span><br></pre></td></tr></table></figure>

<p>然后在开机的时候会有如下打印：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/LV05-04-%E6%A0%B9%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F-02-Buildroot-03-Buildroot%E6%9E%84%E5%BB%BArootfs/img/image-20241128001339253.png" alt="image-20241128001339253" />

<p>然后输入很长的命令也不会有问题啦。可以看到上面其实出现了报错，主要是因为我们制作的根文件系统没有shopt命令，后来我试了，只写这个也没问题：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">resize</span><br></pre></td></tr></table></figure>

<p>这样也可以重新设置默认终端长度。</p>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/bdadd1c2.html">LV05-04-根文件系统-02-Buildroot-03-Buildroot构建rootfs</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2024年11月29日 - 10:27</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/bdadd1c2.html" title="LV05-04-根文件系统-02-Buildroot-03-Buildroot构建rootfs">https://sumumm.github.io/post/bdadd1c2.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/LV05-%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/" rel="tag"><i class="fa fa-tag"></i> LV05-系统镜像</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/9ba83720.html" rel="prev" title="LV05-04-根文件系统-03-busybox-01-busybox简介">
                  <i class="fa fa-angle-left"></i> LV05-04-根文件系统-03-busybox-01-busybox简介
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/64b1388b.html" rel="next" title="LV05-04-根文件系统-02-Buildroot-02-Buildroot基础">
                  LV05-04-根文件系统-02-Buildroot-02-Buildroot基础 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
